package tp.pr1;

public enum Direction {
	EAST, NORTH, SOUTH, WEST, UNKNOWN;

	public Direction opposite() {
		switch(this) {
		case EAST: return WEST;
		case WEST: return EAST;
		case NORTH: return SOUTH;
		case SOUTH: return NORTH;
		default: return UNKNOWN;
		}
	}
	
	public String sayDirection() {
		return new String("WALL·E is looking at direction " + this.toString());
	}
	
	public String moveDirection() {
		return new String("WALL·E says: Moving in direction " + this.toString());
	}
	
	/**
	 * 
	 * @param rotation
	 * @return resultado de aplicar la rotación rotation a la direccion desde la que se llama al método
	 */
	public Direction nextDirection(Rotation rotation) {

		switch (rotation) {
		case RIGHT:	
			switch (this) {
			case WEST:	return NORTH; 
			case NORTH:	return EAST; 
			case EAST:	return SOUTH;
			case SOUTH: return WEST;
			case UNKNOWN: return UNKNOWN; 
			}
			break;
		case LEFT:
			switch (this) {
			case WEST:	return SOUTH;
			case NORTH:	return WEST;
			case EAST:	return NORTH; 
			case SOUTH: return EAST;
			case UNKNOWN: return UNKNOWN; 
			}
			break;
		default:
			break;
		}
		return UNKNOWN;
	}
}
